


class GroupId:
	types = ['all', 'friends', 'self', 'groupId'];

	def __init__(self, type, groupId):
		self.__type__ = type;
		self.__groupId__ = groupId;

	@staticmethod
	def fromJson(jsonId):
		from lib import Util;

		if (Util.substr(jsonId, 1) in GroupId.types):
			return GroupId(Util.substr(jsonId, 1), None);
		
		return GroupId('groupId', jsonId);
	

	def getGroupId(self):
		return self.__groupId__;
	

	def getType(self):
		return self.__type__;







class MessagesService:

	## message is an array containing the following fields:
	# [id] => msgid
	# [title] => You have an invitation from Joe
	# [body] => Click <a href="http://app.example.org/invites/msgid">here</a> to review your invitation.
	# [recipients] => Array
	#     (
	#         [0] => example.org:AD38B3886625AAF
	#         [1] => example.org:997638BAA6F25AD
	#     )
	
	def createMessage(self, userId, message, token):
		from lib import Util;
		Util.abstract();


class PeopleService:
	#
	#Returns a Person object for person with id or false on not found
	
	#@param container specific id id
	#@param fields set of contact fields to return, as ('fieldName' => 1)
	#@param security token token
	
	def getPerson(userId, groupId, fields, token):
		from lib import Util;
		Util.abstract();


	#Returns a list of people that correspond to the passed in person ids.
	#@param ids The ids of the people to fetch.
	#@param options Request options for filtering/sorting/paging
	#@param fields set of contact fields to return, as ('fieldName' => 1)
	#@return a list of people.
	
	def getPeople(userId, groupId, options, fields, token):
		from lib import Util;
		Util.abstract();


#
#This class represents a RESTful social data response

class RestfulCollection:
	@staticmethod
	def createFromEntry(entry):
		return RestfulCollection(entry, 0, len(entry));
	

	def __init__(self, entry, startIndex, totalResults):
		
		#boolean flags to indicate whether the requested operations were performed or declined
		self.filtered = "";
		self.sorted = "";
		self.updatedSince = "";

		self.entry = entry;
		self.startIndex = startIndex;
		self.totalResults = totalResults;
	
	def getEntry(self):
		return self.entry;
	
	def setEntry(self, entry):
		self.entry = entry;
	
	def getStartIndex(self):
		return self.startIndex;
	
	def setStartIndex(self, startIndex):
		self.startIndex = startIndex;
	
	def getTotalResults(self):
		return self.totalResults;
	
	def setTotalResults(self, totalResults):
		self.totalResults = totalResults;
	
	def getFiltered(self, filtered):
		self.filtered = filtered;
	
	def setFiltered(self, filtered):
		self.filtered = filtered;
	
	def getSorted(self, sorted):
		self.sorted = sorted;
	
	def setSorted(self, sorted):
		self.sorted = sorted;
	
	def getUpdatedSince(self, updatedSince):
		self.updatedSince = updatedSince;
	
	def setUpdatedSince(self, updatedSince):
		self.updatedSince = updatedSince;
	

class UserId:
	types = ['viewer', 'owner', 'userId'];

	def __init__(self, type, userId):
		self.__type_ = type;
		self.__userId_ = userId;
	
	@staticmethod
	def fromJson(jsonId):
		from lib import Util;
		if (Util.substr(jsonId, 1) in UserId.types):
			return UserId(Util.substr(jsonId, 1), None);
		
		return UserId('userId', jsonId);
	
	def getUserId(self, token):
		if (self.__type_ == 'viewer'):
			return token.getViewerId();
			
		elif (self.__type_ == 'owner'):
			return token.getOwnerId();
			
		elif (self.__type_ == 'userId'):
			return self.__userId_;
			
		else:
			raise Exception, "The type field is not a valid enum: " + self.__type_;
			
	
	def getType(self):
		return self.__type_;


class ActivitiesService:

	#*
	#Returns a list of activities that correspond to the passed in person ids.
	#@param ids The ids of the people to fetch activities for.
	#@param token A valid SecurityToken
	#@return a response item with the list of activities.
	
	def getActivities(self,  userId, groupId, first, max, token):
		from lib import Util;
		Util.abstract();
		

	def getActivity(self,  userId, groupId, activityId, first, max, token):
		from lib import Util;
		Util.abstract();


	#*
	#Creates the passed in activity for the given user. Once createActivity is
	#called, getActivities will be able to return the Activity.
	#@param personId The id of the person to create the activity for.
	#@param activity The activity to create.
	#@param token A valid SecurityToken
	#@return a response item containing any errors
	
	def createActivity(self, userId, activity, token):
		from lib import Util;
		Util.abstract();

class AppDataService:

	#*
	#Fetch data for a list of ids.
	#@param UserId The user id to perform the action for
	#@param GroupId optional grouping ID
	#@param fields The list of fields to fetch
	#@param token The SecurityToken for this request
	#@return ResponseItem a response item with the error code set if
	#    there was a problem
	
	def getPersonData(self,  userId, groupId, fields, appId, token):
		from lib import Util;
		Util.abstract();


	def deletePersonData(self,  userId, groupId, fields, appId, token):
		from lib import Util;
		Util.abstract();


	#*
	#Updates the data key for the given person with the value.
	#@param id The person the data is for.
	#@param key The key of the data.
	#@param value The value of the data.
	#@param token The SecurityToken for this request
	#@return ResponseItem a response item with the error code set if
	#    there was a problem
	
	def updatePersonData(self,  userId, groupId, fields, values, appId, token):
		from lib import Util;
		Util.abstract();


#*
#Represents the request options for sorting/filtering/paging.

class CollectionOptions:
	SORT_ORDER_ASCENDING = 'ascending';
	SORT_ORDER_DESCENDING = 'descending';

	FILTER_OP_EQUALS = 'equals';
	FILTER_OP_CONTAINS = 'contains';
	FILTER_OP_STARTSWITH = 'startswith';
	FILTER_OP_PRESENT = 'present';
	
	
	def __init__(self):
		self.__filterBy_ = None;
		self.__filterOp_ = None;
		self.__filterValue_ = None;
		self.__updatedSince_ = None;
		self.__networkDistance_ = None;
		self.__sortBy_ = None;
		
		#set default values, per spec
		self.__startIndex_ = 0;
		self.__count_ = 0;
		self.__sortOrder_ = CollectionOptions.SORT_ORDER_ASCENDING;

	def getSortBy(self):
	
		return self.__sortBy_;
	

	def setSortBy(self, sortBy):
	
		self.__sortBy_ = sortBy;
	

	def getSortOrder(self):
	
		return self.__sortOrder_;
	

	def setSortOrder(self, sortOrder):
	
		self.__sortOrder_ = sortOrder;
	

	def getFilterBy(self):
	
		return self.__filterBy_;
	

	def setFilterBy(self, filterBy):
	
		self.__filterBy_ = filterBy;
	

	def getFilterOperation(self):
	
		return self.__filterOp_;
	

	def setFilterOperation(self, filterOp):
	
		self.__filterOp_ = filterOp;
	

	def getFilterValue(self):
	
		return self.__filterValue_;
	

	def setFilterValue(self, filterValue):
	
		self.__filterValue_ = filterValue;
	

	def getUpdatedSince(self):
	
		return self.__updatedSince_;
	

	def setUpdatedSince(self, updatedSince):
	
		self.__updatedSince_ = updatedSince;
	

	def getNetworkDistance(self):
	
		return self.__networkDistance_;
	

	def setNetworkDistance(self, networkDistance):
	
		self.__networkDistance_ = networkDistance;
	

	def getStartIndex(self):
	
		return self.__startIndex_;
	

	def setStartIndex(self, startIndex):
	
		self.__startIndex_ = startIndex;
	

	def getCount(self):
	
		return self.__count_;
	

	def setCount(self, count):
	
		self.__count_ = count;
	




